#!/usr/bin/env bats

@test "static maps: maps work" {
  cd $BATS_TEST_DIRNAME
  expected="file1:4:HTTP interface port: 80
file1:5:SSH interface port: 29418
file1:6:In this walkthrough, we’ll follow two developers, Max and Hannah, as they make
file1:9:Making the change.
file1:10:Creating the review.
file1:11:Reviewing the change.
file1:12:Reworking the change.
file1:13:Verifying the change.
file1:14:Submitting the change.
file1:16:The project and commands used in this section are for demonstration purposes only.
file1:17:Making the Change
file1:20:modify. To get this code, he runs the following git clone command:
file1:23:to his commits. This ID allows Gerrit to link together different versions of
file1:24:the same change being reviewed.
file1:28:To learn more about adding a change-id and the commit message hook, see the
file1:30:Creating the Review
file1:32:review it. He does this using the git push origin HEAD:refs/for/master command,
file1:37: 1 file changed, 10 insertions(+), 5 deletions(-)
file1:38:$ git push origin HEAD:refs/for/master
file1:39:Counting objects: 3, done.
file1:40:Delta compression using up to 8 threads.
file1:41:Compressing objects: 100% (2/2), done.
file1:42:Writing objects: 100% (3/3), 532 bytes | 0 bytes/s, done.
file1:44:remote: Processing changes: new: 1, done
file1:54:branch, he would have modified his command to git push origin
file1:57:The output of this command also contains a link to a web page Max can use to
file1:58:review this commit. Clicking on that link takes him to a screen similar to the
file1:59:following."
  result="$(fish -c 'tbgs in')"; [ "$result" = "$expected" ]
  expected="file1:6:In this walkthrough, we’ll follow two developers, Max and Hannah, as they make
file1:16:The project and commands used in this section are for demonstration purposes only."
  result="$(fish -c 'tbgs in w')"; [ "$result" = "$expected" ]
  expected="file1:23:to his commits. This ID allows Gerrit to link together different versions of
file1:57:The output of this command also contains a link to a web page Max can use to
file1:58:review this commit. Clicking on that link takes him to a screen similar to the"
  result="$(fish -c 'tbgs link wc')"; [ "$result" = "$expected" ]
  expected=""
  result="$(fish -c 'tbgs lin wc')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs linK wc')"; [ "$result" = "$expected" ]
}

@test "static maps: keyword can escape maps" {
  cd $BATS_TEST_DIRNAME
  expected="Error: There is no search word to search!"
  result="$(fish -c 'tbgs this')"; [ "$result" = "$expected" ]
  expected="file1:2:cycle. This example uses a Gerrit server configured as follows:
file1:6:In this walkthrough, we’ll follow two developers, Max and Hannah, as they make
file1:16:The project and commands used in this section are for demonstration purposes only.
file1:20:modify. To get this code, he runs the following git clone command:
file1:23:to his commits. This ID allows Gerrit to link together different versions of
file1:32:review it. He does this using the git push origin HEAD:refs/for/master command,
file1:52:Notice the reference to a refs/for/master branch. Gerrit uses this branch to
file1:57:The output of this command also contains a link to a web page Max can use to
file1:58:review this commit. Clicking on that link takes him to a screen similar to the"
  result="$(fish -c 'tbgs keyword this')"; [ "$result" = "$expected" ]
  expected="file1:6:In this walkthrough, we’ll follow two developers, Max and Hannah, as they make
file1:16:The project and commands used in this section are for demonstration purposes only.
file1:20:modify. To get this code, he runs the following git clone command:
file1:32:review it. He does this using the git push origin HEAD:refs/for/master command,
file1:52:Notice the reference to a refs/for/master branch. Gerrit uses this branch to
file1:57:The output of this command also contains a link to a web page Max can use to
file1:58:review this commit. Clicking on that link takes him to a screen similar to the"
  result="$(fish -c 'tbgs keyword this this')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs this keyword this')"; [ "$result" = "$expected" ]
}
